home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / fweb / fweb-1.40 / manual / demo3.web < prev    next >
Text File  |  1993-10-29  |  2KB  |  54 lines

  1. @z --- demo3.web --
  2.  
  3. This file is part of FWEB.  Its woven output is included into the user
  4. manual fwebman.tex.  
  5.  
  6. Author:  J. A. Krommes
  7. Version: 1.23
  8. Date:    April 1, 1992
  9.  
  10. @x-----------------------------------------------------------------------------
  11.  
  12. @c @* FORWARD REFERENCING.  Here is a nonsense program illustrating forward
  13. referencing for identifiers.  Although there are various instances of
  14. forward references, there was need for just one explicit~`\.{@@[}' command
  15. (in module~3).  Identifiers that are used in the same section as they are
  16. defined are subscripted with a bullet.  Note how the module-number
  17. subscripts are set in different type for different kinds of identifiers.
  18.  
  19. Here we see that one can refer to the macros~|D| and~|W| as well as the
  20. user-defined type~|PTR| in advance of their definition, yet they will
  21. be subscripted properly.
  22. @a
  23. int main()
  24. {
  25. @<Typedefs@>@;
  26. @<Special stuff@>@;
  27.  
  28. x = fcn(D(outer_test));
  29. py = g(W(WEB_test));
  30. }
  31.  
  32. @ Examples of definitions of an outer macro, a \WEB\ macro, and a function.
  33. @d D(name) #name
  34. @m W(arg) *arg++
  35. @a
  36. int fcn(char *name)
  37. {}
  38.  
  39. @ In the following, we had to say ``\.{PTR\ @@[g\dots}'' in order to make
  40. forward referencing to~|g| work.  Although one can say things like
  41. ``\.{@@[int\ g\dots}'', it wouldn't work here to say ``\.{@@[PTR\ g\dots}''
  42. because |PTR|~isn't known yet as a special type, even in phase~1.
  43. @<Special...@>=
  44. PTR @[g(int i)
  45. {}
  46.  
  47. @ The compiler will see this |typedef| before any statements that use the
  48. type |PTR|.
  49. @<Type...@>=
  50.  
  51. typedef char *PTR;
  52.  
  53. @* INDEX.
  54.